from django.shortcuts import render

# Create your views here.
from rest_framework.viewsets import GenericViewSet
from utils.view import CommonListModelMixin
from .serializer import ClassifySerializer, CategorySerializer
from .models import Classification, Category
from django_filters.rest_framework import DjangoFilterBackend


class ClassifyView(GenericViewSet, CommonListModelMixin):
    queryset = Classification.objects.all().filter(is_delete=False, is_show=True).order_by('orders')
    serializer_class = ClassifySerializer


class OneCategory(GenericViewSet, CommonListModelMixin):
    queryset = Category.objects.all().filter(is_delete=False, is_show=True).order_by('orders')
    serializer_class = CategorySerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ['category_level']


class TwoCategory(GenericViewSet, CommonListModelMixin):
    queryset = Category.objects.all().filter(is_delete=False, is_show=True).order_by('orders')
    serializer_class = CategorySerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ['parent_id']
